﻿using B.S.Data.MES.API.Applications.ProcessrouteApplication;
using B.S.Data.MES.API.Dto.DTOProcess;
using B.S.Domain.Process.ProcessrouteName;
using B.S.Requst;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace B.S.Data.MES.API.Controllers
{
    /// <summary>
    /// 工艺路线
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ProcessrouteController : ControllerBase
    {
        IMediator mediator;

        public ProcessrouteController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 查询工艺路线列表
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]

        public async Task<APIPageing<List<DtoProcessroute>>> ShowProcessroute([FromQuery]ShowProcessrouteCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 新增工艺路线
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIRequst<int>> AddProcessroute(AddProcessrouteCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 修改工艺路线
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIRequst<int>> UpdateProcessroute([FromBody]UpdateProcessrouteCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 逻辑删除工艺路线
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIRequst<int>> DeleteProcessroute([FromBody]DeleteProcessrouteCommand request, CancellationToken cancellationToken)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 修改工艺路线状态,发布
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIRequst<int>> UpdateStateProcessroute([FromBody]UpdateStateProcessrouteCommandFB request)
        {
          return await mediator.Send(request);
        }
        /// <summary>
        /// 修改工艺路线状态，未发布
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIRequst<int>> UpdateStateProcessrouteTow(UpdateStateProcessrouteCommandFBTow request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// <summary>
        /// 修改图片节点
        /// </summary>
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIRequst<int>> Updateimagenodes([FromBody]UpdateimagenodesCommand request)
        {
            return await mediator.Send(request);
        }
    }
}
